#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
//1.计算n的阶乘
int main()
{
	int i = 0;
	int n = 0;
	int ret = 1;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)  
	{
		ret *= i;
	}
	printf("%d\n", ret);
	return 0; 
}
int main()
{
	int i = 0;
	int n = 0;
	int ret = 1;
	int sum = 0;

	for (n = 1; n <= 1; n++)
	{
		ret = 1;//计算n的阶乘之前，把ret初始化为1
		for (i = 1; i <= n; i++)
		{
			ret *= i;
			
		}
		sum += ret;
	}

	for (n = 1; n <= 3; n++)
	{
		ret *= n;
		sum += ret;
	}

	printf("%d\n", sum);
	return 0;
}


//2.在一个有序数组中查找具体的数字n(折半查找、二分查找)
int main()
{
	int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
	int k = 7;//要查找的数字
	//在arr这个有序数字查找k(7)的值
	int sz = sizeof(arr) / sizeof(arr[0]);//数组元素个数
	int left = 0;
	int right = sz - 1;
	while (left <= right)
	{
		int mid = (left + right) / 2;
		if (arr[mid] < k)
		{
			left = mid + 1;
		}
		else if(arr[mid]>k)
		{
			right = mid - 1;
		}
		else
		{
			printf("找到了，下标是:%d\n", mid);
			break;
		}
	}
	if (left > right)
	{
		printf("找不到了\n");
	}
	return 0;
}